<h1>New room</h1>

<%= error_messages_for :room %>

<% form_for [Agency.find(params[:agency_id]), Site.find(params[:site_id]), @room] do |f| %>
  <p>
    <b>Location</b><br />
    <%= f.text_field :location %>
  </p>
  <p>
    <b>Number of Beds</b><br />
    <%= f.text_field :number_of_beds %>
  </p>
  
  <table>
    <tr>
      <td>
        <% fields_for :criteria do |c| %>
        <fieldset id="criteria">
          <legend>Must have these criteria</legend>
    
          <% Criteria.find(:all).each do |criteria| %>
          <p>
            <%= c.check_box criteria.id %> <%= criteria.name %>
          </p>
          <% end -%>    
        </fieldset>
        <% end -%>
      </td>
      <td>
        <% fields_for :not_criteria do |c| %>
          <fieldset id="criteria">
            <legend>Cannot have these criteria</legend>
  
            <% Criteria.find(:all).each do |criteria| %>
            <p>
              <%= c.check_box criteria.id %> <%= criteria.name %>
            </p>
            <% end -%>    
          </fieldset>
        <% end -%>
      </td>
    </tr>
  </table>

  <p>
    <%= f.submit "Create" %>
  </p>
<% end %>

<%= link_to 'Back', agency_site_rooms_path(params[:agency_id], params[:site_id]) %>
